﻿@{
    ViewBag.Title = "评论管理";
    List<SelectListItem> propertyList = new List<SelectListItem>() {
        new SelectListItem(){ Text="所有属性", Value=""},
        new SelectListItem(){ Text="未审核", Value="isLock"},
        new SelectListItem(){ Text="已审核", Value="unLock"}
    };
    int channel_id = ViewBag.channel_id;
}
@section HeaderContent{
    <style type="text/css">
        .layui-table-view .layui-table[lay-size=lg] .layui-table-cell {
            height: 65px;
            line-height: 65px
        }
    </style>
}
<div class="pageheader">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
            <li><a href="javascript:;">内容管理</a> </li>
            <li><a href="javascript:;">评论列表</a> </li>
        </ul>
    </div>
</div>
<div class="layui-fluid">
    <div class="layui-card layui-tab">
        <div class="layui-card-body table-tool-mini">
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="menu-list">
                        <div class="layui-inline">
                            <div class="layui-input-inline mr0">
                                <input id="txtKeywords" class="layui-input" type="text" placeholder="输入关键字" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn layui-btn-normal layui-btn-sm" id="btnSearchAuth" data-type="btnSearch">
                                <i class="layui-icon">&#xe615;</i>搜索
                            </button>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-btn-group">
                            <a data-type="btnAudit" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="iconfont icon-survey"></i><span> 审核</span></a>
                            <a data-type="btnDelete" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i class="iconfont icon-delete"></i><span> 删除</span></a>
                        </div>
                        <div class="menu-select">
                            @Html.DropDownList("ddlProperty", new SelectList(propertyList, "Value", "Text"), new { @lay_filter = "btnSearch" })
                        </div>
                    </div>
                </div>
            </div>
            <table class="layui-table" lay-data="{page:true, id:'ltable'}" lay-filter="ltable">
                <thead>
                    <tr>
                        <th lay-data="{checkbox:true}"></th>
                        <th lay-data="{field:'status',templet: '#comment'}">内容</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>
<script type="text/html" id="comment">
    <div class="comment">
        <div class="title">
            <span class="note"><i>{{d.user_name}}</i><i>{{d.add_time}}</i><i class="reply"><a href="../article/comment_edit?id={{d.id}}">回复</a></i></span>
            <a href="javascript:;" target="_blank">{{d.ArticleTitle}}</a>
        </div>
        <div class="ask">
            {{# if(d.is_lock == 1){ }}
            <b class="audit">待审核</b>
            {{# } }}
            {{d.content}}
            {{# if(d.is_reply == 1){ }}
            <div class="answer"><b>管理员回复：</b>{{d.reply_content}}<span class="time">{{d.reply_time}}</span></div>
            {{# } }}
        </div>
    </div>
</script>
@section Scripts{
    <script type="text/javascript">
        layui.use(['table', 'cmswh'], function () {
            var table = layui.table, cmswh = layui.cmswh, $ = layui.jquery;
            cmswh.dataBind('commentList?channel_id=@channel_id');

            var active = {
                btnAudit: function () {
                    cmswh.batOperate('commentAudit?channel_id=@channel_id', 'id', "审核后前台将显示该信息，确定继续吗？");
                },
                btnDelete: function () {
                    cmswh.batOperate('commentDelete?channel_id=@channel_id', 'id');
                },
                btnSearch: function () {
                    table.reload('ltable', { page: { curr: 1 }, where: getcond() });
                }
            };
            $('.layui-inline .layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
            /*拼接条件返回postdata*/
            function getcond() {
                var keywords = $("#txtKeywords").val();
                var propertyType = $("#ddlProperty").val();
                var postdata = { keywords: keywords, property: propertyType };
                return postdata;
            }
        })
    </script>
}